﻿Imports ajayumi.develop.win32.GRssReader.Google.Reader
Imports ajayumi.develop.win32.GRssReader.Service.Model
Imports System.ComponentModel

''' <summary>
''' Feed处理的基类
''' </summary>
''' <remarks></remarks>
Public MustInherit Class FeedServiceBase
    Implements IDisposable


#Region "Variables"


#End Region

#Region "Properties"

    Protected m_ArticleInfoList As List(Of ArticleInfo) = Nothing
    Public ReadOnly Property [ArticleInfoList]() As List(Of ArticleInfo)
        Get
            Return Me.m_ArticleInfoList
        End Get
    End Property

    Protected m_SubscriptionInfo As SubscriptionInfo = Nothing
    Public ReadOnly Property [SubscriptionInfo]() As SubscriptionInfo
        Get
            Return m_SubscriptionInfo
        End Get
    End Property

#End Region

#Region "Events"
    Public Event GetArticleImageProgressChanged As Action(Of Object, GetArticleImageProgressChangedEventArgs)
    Protected Overridable Sub OnGetArticleImageProgressChanged(e As GetArticleImageProgressChangedEventArgs)
        RaiseEvent GetArticleImageProgressChanged(Me, e)
    End Sub

    Public Event GetArticleCompleted As Action(Of Object, GetArticleInfoListCompleted)
    Protected Overridable Sub OnGetArticleCompleted(e As GetArticleInfoListCompleted)
        RaiseEvent GetArticleCompleted(Me, e)
    End Sub
#End Region

    Public Sub New(subscriptionInfo As SubscriptionInfo)
        Me.m_SubscriptionInfo = subscriptionInfo
        Me.m_ArticleInfoList = New List(Of ArticleInfo)()
    End Sub

    Public Overridable Sub GetArticleInfos()
        Me.GetArticleInfos(Me.m_SubscriptionInfo.UnReadCount)
    End Sub

    Public MustOverride Sub GetArticleInfos(count As Integer)

    ''' <summary>
    ''' 清除本地缓存的Feed文章资源，如图片...
    ''' </summary>
    ''' <remarks></remarks>
    Public MustOverride Sub Clear()

#Region "IDisposable Support"
    Private disposedValue As Boolean ' 检测冗余的调用

    ' IDisposable
    Protected Overridable Sub Dispose(disposing As Boolean)
        If Not Me.disposedValue Then
            If disposing Then
                ' TODO: 释放托管状态(托管对象)。
            End If

            ' TODO: 释放非托管资源(非托管对象)并重写下面的 Finalize()。
            ' TODO: 将大型字段设置为 null。
        End If
        Me.disposedValue = True
    End Sub

    ' TODO: 仅当上面的 Dispose(ByVal disposing As Boolean)具有释放非托管资源的代码时重写 Finalize()。
    'Protected Overrides Sub Finalize()
    '    ' 不要更改此代码。请将清理代码放入上面的 Dispose(ByVal disposing As Boolean)中。
    '    Dispose(False)
    '    MyBase.Finalize()
    'End Sub

    ' Visual Basic 添加此代码是为了正确实现可处置模式。
    Public Sub Dispose() Implements IDisposable.Dispose
        ' 不要更改此代码。请将清理代码放入上面的 Dispose(ByVal disposing As Boolean)中。
        Dispose(True)
        GC.SuppressFinalize(Me)
    End Sub
#End Region

End Class
